﻿<Button x:Class="Domino.Tile"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:domino="clr-namespace:Domino" mc:Ignorable="d" Margin="0.5,0"
             IsEnabled="{Binding IsPlayable}">
    <Button.Resources>
        <domino:PlayableTileConverter x:Key="PlayableTileConverter" />
    </Button.Resources>
    <Button.Template>
        <ControlTemplate x:Name="template" TargetType="Button">
            <ContentPresenter>
                <ContentPresenter.Content>
                    <Grid Opacity="{Binding IsPlayable, Converter={StaticResource PlayableTileConverter}, ConverterParameter='0.5'}">
                        <Grid.Resources>
                            <domino:TileOrientationConverter x:Key="TileOrientationConverter" />
                        </Grid.Resources>
                        <domino:TileHorizontal x:Name="tileH" TilePairValue="{Binding TilePairValue}" 
                                               Visibility="{Binding TileOrientation, Converter={StaticResource TileOrientationConverter}, ConverterParameter={x:Static domino:eTileOrientation.Horizontal}}" />
                        <domino:TileVertical x:Name="tileV" TilePairValue="{Binding TilePairValue}" 
                                             Visibility="{Binding TileOrientation, Converter={StaticResource TileOrientationConverter}, ConverterParameter={x:Static domino:eTileOrientation.Vertical}}" />
                    </Grid>
                </ContentPresenter.Content>
            </ContentPresenter>
        </ControlTemplate>
    </Button.Template>
</Button>
